home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group93c.txt
/
000001_icon-group-sender _Wed Jun 30 16:35:14 1993.msg
< prev
next >
Wrap
Internet Message Format
|
1994-02-02
|
1KB
Received: from owl.CS.Arizona.EDU by cheltenham.CS.Arizona.EDU; Wed, 30 Jun 1993 15:48:54 MST
Received: by owl.cs.arizona.edu; Wed, 30 Jun 1993 15:48:53 MST
Date: Wed, 30 Jun 93 16:35:14 EDT
From: Paul_Abrahams@MTS.cc.Wayne.edu
To: icon-group@cs.arizona.edu
Message-Id: <692691@MTS.cc.Wayne.edu>
Subject: Tables versus lists
Status: R
Errors-To: icon-group-errors@cs.arizona.edu
Suppose that I have a "growing array" whose elements I frequently
reference. I can implement that array in Icon in either of two ways: as
a list or as a table. The construct for referencing an array element is
the same in either case: array[n]. The constructs for adding an element
are different, but not that different:
push(array, element)
versus
array[integer(*array+1)] := element
My question is: how do the efficiencies of these constructs compare? I
know that lists are implemented efficiently if allocated all at once, but
how about the case where they grow an element at a time? If finding an
element requires a search down a linked list with hundreds of items, the
table is clearly preferable; but if finding an element in the list can be
done with an integer-indexed lookup, the list is clearly preferable.
This is a good example of a choice in Icon that is difficult to make
intelligently without a knowledge of the implementation and that can make
a great difference in performance.
Paul Abrahams
Reply-To: abrahams@acm.org